package com.ruoyi.order.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.order.domain.CfDrawal;
import com.ruoyi.order.service.ICfDrawalService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商家提现记录Controller
 * 
 * @author ruoyi
 * @date 2024-06-04
 */
@RestController
@RequestMapping("/drawal")
public class CfDrawalController extends BaseController
{
    @Autowired
    private ICfDrawalService cfDrawalService;

    /**
     * 查询商家提现记录列表
     */
//    @RequiresPermissions("order:drawal:list")
    @GetMapping("/list")
    public TableDataInfo list(CfDrawal cfDrawal)
    {
        startPage();
        List<CfDrawal> list = cfDrawalService.selectCfDrawalList(cfDrawal);
        return getDataTable(list);
    }

    /**
     * 导出商家提现记录列表
     */
    @RequiresPermissions("order:drawal:export")
    @Log(title = "商家提现记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CfDrawal cfDrawal)
    {
        List<CfDrawal> list = cfDrawalService.selectCfDrawalList(cfDrawal);
        ExcelUtil<CfDrawal> util = new ExcelUtil<CfDrawal>(CfDrawal.class);
        util.exportExcel(response, list, "商家提现记录数据");
    }

    /**
     * 获取商家提现记录详细信息
     */
    @RequiresPermissions("order:drawal:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cfDrawalService.selectCfDrawalById(id));
    }

    /**
     * 新增商家提现记录
     */
//    @RequiresPermissions("order:drawal:add")
    @Log(title = "商家提现记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CfDrawal cfDrawal)
    {
        return toAjax(cfDrawalService.insertCfDrawal(cfDrawal));
    }

    /**
     * 修改商家提现记录
     */
    @RequiresPermissions("order:drawal:edit")
    @Log(title = "商家提现记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CfDrawal cfDrawal)
    {
        return toAjax(cfDrawalService.updateCfDrawal(cfDrawal));
    }

    /**
     * 删除商家提现记录
     */
    @RequiresPermissions("order:drawal:remove")
    @Log(title = "商家提现记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cfDrawalService.deleteCfDrawalByIds(ids));
    }
}
